<template>
  <div class="bg">
    <!-- 头部 -->
    <Header title="系统管理—新闻管理"></Header>

    <!-- 搜索栏 -->
    <section class="search_bar">
      <LSelect label="栏目名称" v-model="a" :options="option1" @selected-event="getNewSelect"></LSelect>
      <LButton label="查询数据" style="margin-left: 16px"></LButton>
      <LButton label="写新闻" style="margin-left: 16px" @click="goTo"></LButton>
    </section>
    <!-- 表格 -->
    <el-table :data="tableData" style="width: 100%" :default-sort="{prop:'b',order:descending}" border>
      <el-table-column label="新闻内容标题" prop="a" />
      <el-table-column label="栏目名称" prop="b" />
      <el-table-column label="日期" prop="c" />
      <el-table-column label="作者" prop="d" />
      <el-table-column label="是否推荐" prop="e" />
      <el-table-column label="操作" width="210">
        <template #default="scope">
          <el-button type="success" size="mini" @click="goTo1">查看</el-button>
          <el-button type="primary" size="mini" @click="goTo2(scope.row)">编辑</el-button>
          <el-button type="danger" size="mini" @click="del">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import Header from "@/components/Header";
import moment from "moment";
import LInput from "../../../components/LInput.vue";
import LDateTimeSelect2 from "../../../components/LDateTimeSelect2.vue";
import LButton from "../../../components/LButton.vue";
import LSelect from "@/components/LSelect.vue";

export default {
  components: {
    Header,
    LInput,
    LDateTimeSelect2,
    LButton,
    LSelect,
  },
  data() {
    return {
      a: "",
      tableData: [
        {
          a: "2021年梁山县节约型机关创建工作会",
          b: "栏目名称",
          c: "2022-02-22 9:38:12",
          d: "",
          e: "已推荐",
        },
      ],
    };
  },
  mounted() {},
  beforeUnmount() {},
  methods: {
    //编辑
    goTo() {
      this.$router.push({ path: "/add-news" });
    },
    //查看
    goTo1() {
      console.log("查看");
      this.$router.push("/search");
    },
    //编辑
    goTo2(row) {
      console.log("编辑");
      console.log(row);
      this.$router.push("/edit");
    },
    //删除数据按钮
    del() {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          // post("/airChannel/deleteAirChannel", { id: id }).then((res) => {
          //   // console.log(res);
          //   if (res.data.code == 200) {
          //     this.$message.success(res.data.data);
          //     this.getData();
          //   } else {
          //     this.$message.error(res.data.data);
          //   }
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>


<style lang="less" scoped>
@import "../../OperaManage/opera.less";

.search_bar {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.row-1 {
  display: flex;
  justify-content: space-between;
  padding: 0 2vw 0 0;
}
</style>